package com.sphd.beautysalon.base;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.sphd.beautysalon.R;
import com.sphd.beautysalon.info.RestaurantInfo;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by Hu on 2016/7/25.
 */
public class DialogAdapter extends BaseAdapter {
    Context context;
    List<RestaurantInfo> restaurantInfos;

    public DialogAdapter(Context context, List<RestaurantInfo> restaurantInfos) {
        this.context=context;
        this.restaurantInfos=restaurantInfos;
    }

    @Override
    public int getCount() {
        return restaurantInfos.size();
    }

    @Override
    public Object getItem(int position) {
        return position;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder=null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.item_dialog, null);
            viewHolder =new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.cgName.setText(restaurantInfos.get(position).getCg_name());
        return convertView;
    }

    static class ViewHolder {
        @BindView(R.id.cg_name)
        TextView cgName;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
